Xbasic

FOR ... CONTINUE ... NEXT

Description

Creates a for loop wherein parts of the loop can be skipped, using 'continue'.

Discussion

Here continue is placed in a for loop. When the program hits continue then it skips back up to the next part of the loop. For example, the code below is a loop designed to display the numbers 1 through 20. However, the continue statement means that if the number involved is between 10 and 15, then the result should be ignored and the program should keep on counting up.

Example

dim txt as c = ""
for i = 1 to 20
   txt = txt + i + crlf()
next
showvar(txt)   
dim txt as c = ""
for i = 1 to 20
   if 10 <= i .and. i <= 15 then
        continue
   end if
   txt = txt + i + crlf()
next
showvar(txt)

See Also